package com.test.testThread;

import com.google.common.collect.Lists;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by shuangjun.yang on 2016/3/4.
 */
public class Threads {
    public static ExecutorService service = Executors.newFixedThreadPool(100);
    static Collection<Callable<Integer>> lists = Lists.newArrayList();
    public static  void main(String[] args){
        for(int i = 0 ;i<10000000 ; i++){
            lists.add(new Callable() {
                @Override
                public Object call() throws Exception {
                    return TestThread.get();
                }
            });
            if(i%1000 == 0){
                try {
                    service.invokeAll(lists);
                    System.out.println(TestThread.get());
                    lists.clear();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }


    }

}
